home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
010
/
joystick.arc
/
JOYSTICK.ASM
next >
Wrap
Assembly Source File
|
1980-01-01
|
5KB
|
225 lines
;Joystick Display
;Display Joystick Coordinates on Screen in Hex
;Mark Hansen 2/86
Port equ 201h
Doscall equ 21h
video equ 10h
count equ 26d
count1 equ 43d
count2 equ 31d
count3 equ 16d
;***********************************************************
stackhere segment stack ;define stack segment
db 20 dup ('stack ')
stackhere ends
;***********************************************************
data segment ;Define segment
Xcoordinate dw ? ;place to store x coord
Ycoordinate dw ? ;place to store y coord
;Strings to be printed
header db 'Xcoordinate Ycoordinate'
blab db 'Use bits of this program as a sub-procedure'
blab1 db 'of another program if you like.'
blab2 db 'Mark Hansen 2/86'
data ends
;***********************************************************
code segment ;define code segment
;-----------------------------------------------------------
main proc far ;main part of prognam
assume cs:code,ds:data
start: ;starting execution address
;set up stack for return
push ds ;save old data segment
sub ax,ax ;put zero an ax
push ax ;save it on stack
;set ds register to current data segment
mov ax,data ;datarea segment addr
mov ds,ax ;into ds register
mov ah,6 ;clear screen using
mov al,0 ;scroll up function
mov ch,0 ;upper left row
mov cl,0 ;upper left column
mov dh,24d ;lower right row
mov dl,79d ;lower right column
mov bh,7 ;blank line attribute
int video
; Print Coordinate String
;---------------------------------------------
mov bx,0
mov ah,2h
mov dh,1h ;move cursor to row 1
mov dl,0h ;column 0
int video ;through BIOS
mov cx,count ;put # of chars on screen
mov bx,offset header ;address of string
nextcharacter:
mov dl,[bx] ;put 1 char in DL
mov ah,2 ;Display character function
int doscall ;call DOS
inc bx ;advance the pointer
loop nextcharacter ;go back for another
; Print Blab
;--------------------------------------------------
mov bx,0 ;page 0
mov ah,2h
mov dh,7d ;move cursor to row 7
mov dl,30d ;column 30
int video ;through BIOS
mov cx,count1 ;put # of chars on screen
mov bx,offset blab ;address of string
morebs:
mov dl,[bx] ;put 1 char in DL
mov ah,2 ;Display character function
int doscall ;call DOS
inc bx ;advance the pointer
loop morebs ;go back for another
mov bx,0 ;page 0
mov ah,2h
mov dh,8d ;move cursor to row 8
mov dl,30d ;column 30
int video ;through BIOS
mov cx,count2 ;put # of chars on screen
mov bx,offset blab1 ;address of string
morebs1:
mov dl,[bx] ;put 1 char in DL
mov ah,2 ;Display character function
int doscall ;call DOS
inc bx ;advance the pointer
loop morebs1 ;go back for another
mov bx,0 ;page 0
mov ah,2h
mov dh,9d ;move cursor to row 9
mov dl,30d ;column 30
int video ;through BIOS
mov cx,count3 ;put # of chars on screen
mov bx,offset blab2 ;address of string
morebs2:
mov dl,[bx] ;put 1 char in DL
mov ah,2 ;Display character function
int doscall ;call DOS
inc bx ;advance the pointer
loop morebs2 ;go back for another
doit:
;Main
mov bx,0 ;page 0
mov ah,2h
mov dh,4h ;move cursor to row 4
mov dl,0 ;column 0
int video ;through BIOS
redo: mov dx,port ;move address of port in dx
mov bx,0 ;bx to zero
out dx,al ;initalize timer on game card
inputx: in al,dx ;input port to al
inc bx ;add 1 to x coordinate
and al,01h ;mask off all but bit 0
cmp al,0 ;see if zero yet
jnz inputx ;jump back, try again
mov xcoordinate,bx ;store x coordinate
call print ;output to screen
sub bx,bx ;bx to zero
mov ah,2h
mov dh,4h ;move cursor to row 4
mov dl,10h ;column 16
int video ;through BIOS
mov dx,port ;port adress
out dx,al ;initialize timer
inputy: in al,dx ;input port to al
inc bx ;add 1 to y coordinate
and al,02h ;mask off all but bit 1
cmp al,0 ;see if zero yet
jnz inputy ;if not, continue to check
mov ycoordinate,bx ;store y coordinate
call print ;output to screen
jmp doit
ret ;return to dos
main endp ;end of main part of program
;----------------------------------------------------------
print proc near ;define subprocedure
mov ch,4 ;number of digits
rotate: mov cl,4 ;set count to four bits
rol bx,cl ;left digit to right
mov al,bl ;mov to al
and al,0fh ,mask off left digit
add al,30h ;convert hex to ascii
cmp al,3ah ;is it greater then 9
jl printmore ;jump if 0 to 9
add al,7h ;digit is A to F
printmore:
mov dl,al ;put ascii character in dl
mov ah,2
int doscall ;through BIOS
dec ch ;done 4 digits yet
jnz rotate ;not yet
ret ;return to main program
print endp ;end subprocedure
;-----------------------------------------------------------
code ends ;end of code segment
;***********************************************************
end start ;end assembly